package com.xbts.web.controller.sms;

import com.xbts.common.annotation.RateLimiter;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.common.enums.LimitType;
import com.xbts.common.enums.SmsTemplateEnum;
import com.xbts.system.domain.dto.SmsDTO;
import com.xbts.system.service.ISmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 短信发送Controller
 */
@RestController
@RequestMapping("/sms")
public class SmsController extends BaseController {

    @Autowired
    private ISmsService smsService;

    /**
     * 发送短信
     * @param smsDTO 短信信息
     * @param smsTemplateEnum 短信模板
     * @return 结果
     */
    @RateLimiter(key = "#smsDTO.phone", count = 10, time = 86400)
    @RequestMapping(value = "/sendMsg/{smsTemplateEnum}", method = RequestMethod.POST)
    public AjaxResult sendMsg(@RequestBody SmsDTO smsDTO, @PathVariable SmsTemplateEnum smsTemplateEnum){
        return success(smsService.sendMsg(smsDTO, smsTemplateEnum));
    }

}
